package im.xz.cn.lovelycreeper;
import org.bukkit.Location;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
public class qwq implements Listener {
    @EventHandler
    public void awa(EntityExplodeEvent event) {
        Plugin plugin = LovelyCreeper.getPlugin(LovelyCreeper.class);
        Location location = event.getLocation();
        try {
            if (event.getEntity().getType().equals(EntityType.CREEPER)) {
                try {
                    if (plugin.getConfig().getBoolean("disableCreeperBreak")) {
                        event.setCancelled(true);
                        Object[] o = location.getNearbyPlayers(8).toArray();
                        for (int i = 0 ; i < o.length ;i++) {
                            Player player = (Player) o[i];
                            if (player.isBlocking()) {
                                player.setNoDamageTicks(1);
                            }
                        }
                        location.createExplosion(3,false,false);
                    }
                }catch (NullPointerException ignore) {
                }
            }else if (event.getEntity().getType().equals(EntityType.TNT)) {
                try {
                    if (plugin.getConfig().getBoolean("disableTNTBreak")) {
                        event.setCancelled(true);
                        Object[] o = location.getNearbyPlayers(8).toArray();
                        for (int i = 0 ; i < o.length ;i++) {
                            Player player = (Player) o[i];
                            if (player.isBlocking()) {
                                player.setNoDamageTicks(1);
                            }
                        }
                        location.createExplosion(3,false,false);
                    }
                }catch (NullPointerException ignore) {
                }
            }
        }catch (NullPointerException ignore) {
        }
    }
}